<div class="row m-n">
    <div class="crumbs-bar">
        <div yb-crumbs></div>
    </div>
    <div tabset type="tab">
        <div tab heading="辅料管理" active="activeFlag[0]" ng-click="changeTab(0)">
            <div class="row wrapper-y-sm">
                <div class="operate-bar col-xs-4 font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="addData()">新增</button>
                    <button class="btn btn-operate m-r-sm" ng-click="delBatch()">删除</button>
                </div>
                <div class="search-bar wrapper-none col-xs-8">
                    <div class="btn-group m-l-xs pull-right">
                        <button type="button" class="btn btn-default base-color" ng-click="search()" title="刷新">
                            <i class="yb-icon ico-refresh"></i>
                        </button>
                        <button type="button" class="btn btn-default base-color" title="配置表格列"
                                ng-click="switchToolbar('ColConfig');">
                            <i class="yb-icon ico-set"></i>
                        </button>
                        <div class="btn btn-default base-color">
                            <div title="导出" yb-download download-url="exportParam.allUrl" download-param="condition" download-duration="3">
                                <i class="yb-icon ico-export-o"></i>
                            </div>
                        </div>

                    </div>
                    <button class="btn-advance pull-right m-l-xs" ng-click="switchToolbar('AdvanceSearch')">高级搜索</button>
                    <div class="input-group pull-right clearfix">
                        <input type="text" class="form-control txt-search" ng-model="condition.materialsNo" placeholder="零件编号">
                        <span class="input-group-addon cursor-pointer" ng-click="search(1)">搜索</span>
                    </div>
                </div>
            </div>
            <div yb-advance-search show-toolbar="toolbarConfig.showAdvanceSearch" search-data="search(1)" reset-data="reset()" date-picker="true"  hide-date="switchDataPicker()">
                <div class="advance-search m-t-sm">
                    <div class="form-group clearfix">
                        <label class="control-label">零件编号：</label>
                        <input type="text" name="saleNo" ng-model="condition.materialsNo" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">零件中文名：</label>
                        <input type="text" name="materialsNo" ng-model="condition.materialsDesc" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">辅料零件号：</label>
                        <input type="text" name="saleNo" ng-model="condition.excipientNo" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">辅料零件中文名：</label>
                        <input type="text" name="materialsNo" ng-model="condition.excipientDesc" class="form-control">
                    </div>
                </div>
            </div>
            <div yb-col-config show-toolbar="toolbarConfig.showColConfig" ng-model="tbConf" col-fixed="true"
                 has-check-col="true" set-tb-style="setFixedWidth()"></div>
            <div class="main-area">
                <div yb-table-fixed class="table-fixed-wrap fix-left" ele-count="4" scroll-area="right">
                    <div class="th-fixed">
                        <table class="table-fixed border-none" width="{{tbConf.fixedWidth}}">
                            <thead>
                            <tr>
                                <th width="40" class="th-check text-center border-l-none">
                                    <div yb-check-box yb-checked="markInfo.allCheckedBill" yb-click="selectAll(dataList, 'Bill')"></div>
                                </th>
                                <th ng-repeat="itemCol in tbConf.tableCol track by $index" width="{{itemCol.width}}"
                                    ng-click="toSort(tableConfig.tableCol, $index)"
                                    ng-show="!!itemCol.isShow && !!itemCol.isFixed">
                                    <div yb-thead-operate ng-model="itemCol" target-width="tbConf.fixedWidth" fixed-width="tbStyle.fixedWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="th-scroll-x" ng-style="tbStyle.fixedWidth">
                        <table class="table-fixed border-none" width="{{tbConf.scrollWidth}}">
                            <thead>
                            <tr>
                                <th ng-repeat="itemCol in tbConf.tableCol track by $index" width="{{itemCol.width}}"
                                    ng-click="toSort(tbConf.tableCol, $index)" ng-show="!!itemCol.isShow && !itemCol.isFixed">
                                    <div yb-thead-operate ng-model="itemCol" target-width="tbConf.scrollWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll-y">
                        <table class="table-fixed border-none" width="{{tbConf.fixedWidth}}">
                            <tbody>
                            <tr ng-repeat="item in dataList track by $index" ng-click="selectRow($index)"
                                ng-class="{'row-selected': $index === markInfo.curRow}">
                                <td width="40" class="text-center border-l-none">
                                    <div yb-check-box yb-checked="item.isChecked" yb-click="selectSingle(item, dataList, 'Bill')"></div>
                                </td>
                                <td class="spill-dots" ng-repeat="itemCol in tbConf.tableCol track by $index" width="{{itemCol.width}}"
                                    ng-show="!!itemCol.isShow && !!itemCol.isFixed" title="{{item[itemCol.dataField]}}">
                                    <span ng-if="(!itemCol.clickFn && itemCol.type !== 'operate') || !!itemCol.clickFn && itemCol.type == 'synSap' && item[itemCol.dataField] != '同步失败'">{{item[itemCol.dataField]}}</span>
                                    <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)" ng-if="(!!itemCol.clickFn && itemCol.type != 'synSap') || (!!itemCol.clickFn && itemCol.type == 'synSap' && item[itemCol.dataField] == '同步失败')">
                                        {{item[itemCol.dataField]}}
                                    </a>
                                    <div class="font-0" ng-if="itemCol.type === 'operate'">
                                        <button class="btn btn-operate m-r-xs" ng-click="editData(item)">编辑</button>
                                        <button class="btn btn-operate m-r-xs" ng-click="delSign(item.id)">删除</button>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="dataList.length > 0" ng-style="tbStyle.fixedWidth">
                        <table class="table-fixed border-none" width="{{tbConf.scrollWidth}}">
                            <tbody>
                            <tr ng-repeat="item in dataList track by $index" ng-click="selectRow($index)"
                                ng-class="{'row-selected': $index === markInfo.curRow}" >
                                <td class="spill-dots" ng-repeat="itemCol in tbConf.tableCol track by $index" width="{{itemCol.width}}"
                                    ng-show="!!itemCol.isShow && !itemCol.isFixed"
                                    title="{{item[itemCol.dataField]}}">
                                    <span ng-if="(!itemCol.clickFn && itemCol.type !== 'operate') || !!itemCol.clickFn && itemCol.type == 'synSap' && item[itemCol.dataField] != '同步失败'">{{item[itemCol.dataField]}}</span>
                                    <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)" ng-if="(!!itemCol.clickFn && itemCol.type != 'synSap') || (!!itemCol.clickFn && itemCol.type == 'synSap' && item[itemCol.dataField] == '同步失败')">
                                        {{item[itemCol.dataField]}}
                                    </a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="dataList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area page-bar wrapper-y-sm clearfix">
                <div yb-check-box class="m-t-xs m-r-sm" yb-checked="markInfo.allCheckedBill" yb-check-name="全选"
                     yb-click="selectAll(dataList, 'Bill')"></div>
                <div yb-page-info ng-model="pageInfo" yb-refresh="search()"></div>
            </div>
        </div>

        <div tab heading="新增" active="activeFlag[1]" ng-click="changeTab(1)" ng-if="activeFlag[1]">
            <div class="panel-bar clearfix">
                <div class="pull-left">
                    <i></i>主料
                </div>
            </div>
            <div class="row wrapper-y-xs">
                <div class="col-xs-12 operate-bar font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="selMateriel($event,'showMaterielOriginal')">选择零件</button>
                </div>
            </div>
            <div materiel-selector show-toolbar="toolbarConfig.showMaterielOriginal" ng-if="toolbarConfig.showMaterielOriginal"
                selected-list="materialObj.mainMaterialList" replace-check="true"></div>
            <div class="main-area d-b-60" style="top:105px;height: 100px">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{mainMaterialTbConf.scrollWidth}}">
                            <thead>
                            <tr>
                                <th ng-repeat="itemCol in mainMaterialTbConf.tableCol track by $index" width="{{itemCol.width}}">
                                    <div yb-thead-operate ng-model="itemCol" target-width="mainMaterialTbConf.scrollWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="materialObj.mainMaterialList.length > 0">
                        <table class="table-fixed border-none" width="{{mainMaterialTbConf.scrollWidth}}">
                            <tbody>
                            <tr ng-repeat="item in materialObj.mainMaterialList track by $index">
                                <td ng-repeat="itemCol in mainMaterialTbConf.tableCol track by $index" width="{{itemCol.width}}"
                                    class="spill-dots"
                                    title="{{item[itemCol.dataField]}}">
                                    <div class="spill-dots" ng-if="!itemCol.input">
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)" ng-if="!!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                        <span ng-if="!itemCol.clickFn">
                                        {{item[itemCol.dataField]}}
                                        </span>
                                    </div>

                                    <div ng-if="itemCol.input && itemCol.inputType === 'txt'" class="td-edit pos-r">
                                        <input type="text" class="form-control edit" ng-model="item[itemCol.dataField]"
                                               yb-number-input decimal-places="3" max="99999" min="1" maxlength="9" ng-init="item[itemCol.dataField]=1" disable-decimal="false" decimal-places="3">
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="materialObj.mainMaterialList.length === 0">暂时没有数据</div>
                </div>
            </div>

            <div class="panel-bar clearfix m-t-110">
                <div class="pull-left">
                    <i></i>辅料
                    <span class="m-l-md danger-color">最多只能选择2个辅料</span>
                </div>
            </div>

            <div class="row wrapper-y-xs">
                <div class="col-xs-12 operate-bar font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="selMateriel($event,'showMaterielDismantling')">选择零件</button>

                </div>
            </div>
            <div materiel-selector show-toolbar="toolbarConfig.showMaterielDismantling" ng-if="toolbarConfig.showMaterielDismantling"
                is-purchase="true" dealer-id="orderObj.purchaseOrgId"
                selected-list="materialObj.accessoriesList"></div>
            <div class="main-area d-b-60" style="top:295px;height: 400px">
                <div yb-table-fixed class="table-fixed-wrap" style="bottom: 40px">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{accessoriesListTbConf.scrollWidth}}">
                            <thead>
                            <tr>
                                <th width="60" class="border-l-none">
                                    操作
                                </th>
                                <th ng-repeat="itemCol in accessoriesListTbConf.tableCol track by $index" width="{{itemCol.width}}">
                                    <div yb-thead-operate ng-model="itemCol" target-width="accessoriesListTbConf.scrollWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="materialObj.accessoriesList.length > 0">
                        <table class="table-fixed border-none" width="{{accessoriesListTbConf.scrollWidth}}">
                            <tbody>
                            <tr ng-repeat="item in materialObj.accessoriesList track by $index">
                                <td width="60" class="font-0">
                                    <button class="btn btn-operate" ng-click="delChoosedMaterial($index)">删除</button>
                                </td>
                                <td ng-repeat="itemCol in accessoriesListTbConf.tableCol track by $index" width="{{itemCol.width}}"
                                    title="{{item[itemCol.dataField]}}">
                                    <div class="spill-dots" ng-if="!itemCol.input">
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)" ng-if="!!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                        <span ng-if="!itemCol.clickFn">
                                        {{item[itemCol.dataField]}}
                                        </span>
                                    </div>

                                    <div ng-if="itemCol.input && itemCol.inputType === 'txt'" class="td-edit pos-r">
                                        <input type="text" class="form-control edit"  ng-model="item[itemCol.dataField]"
                                                yb-number-input decimal-places="3" max="99999" min="1" ng-init="item[itemCol.dataField]=1" maxlength="9" disable-decimal="false" decimal-places="3"
                                               ng-class="{'error': !!item.qtyErr}">
                                        <div class="pos-a tool-tips" ng-if="!!item.qtyErr">
                                            <i class="triangle"></i>
                                            <div class="msg">{{item.qtyErrMsg}}</div>
                                        </div>
                                    </div>

                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="materialObj.accessoriesList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center clearfix">
                <button type="button" class="btn btn-primary m-r-sm" ng-click="saveData()">保存</button>
                <button type="button" class="btn btn-default m-r-sm" ng-click="cancel()">取消</button>
            </div>

        </div>

        <div tab heading="编辑" active="activeFlag[2]" ng-click="changeTab(2)" ng-if="activeFlag[2]">
            <div class="panel-bar clearfix">
                <div class="pull-left">
                    <i></i>主料
                </div>
            </div>

            <div materiel-selector show-toolbar="toolbarConfig.showMaterielOriginal" ng-if="toolbarConfig.showMaterielOriginal"
                is-purchase="true" dealer-id="orderObj.purchaseOrgId"
                selected-list="materialObj.mainMaterialList" replace-check="true"></div>
            <div class="main-area d-b-60" style="top:85px;height: 100px">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{mainMaterialTbConf.scrollWidth}}">
                            <thead>
                            <tr>
                                <th ng-repeat="itemCol in mainMaterialTbConf.tableCol track by $index" width="{{itemCol.width}}">
                                    <div yb-thead-operate ng-model="itemCol" target-width="mainMaterialTbConf.scrollWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="materialObj.mainMaterialList.length > 0">
                        <table class="table-fixed border-none" width="{{mainMaterialTbConf.scrollWidth}}">
                            <tbody>
                            <tr ng-repeat="item in materialObj.mainMaterialList track by $index">
                                <td ng-repeat="itemCol in mainMaterialTbConf.tableCol track by $index" width="{{itemCol.width}}"
                                    class="spill-dots"
                                    title="{{item[itemCol.dataField]}}">
                                    <div class="spill-dots" ng-if="!itemCol.input">
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)" ng-if="!!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                        <span ng-if="!itemCol.clickFn">
                                        {{item[itemCol.dataField]}}
                                        </span>
                                    </div>

                                    <div ng-if="itemCol.input && itemCol.inputType === 'txt'" class="td-edit pos-r">
                                        <input type="text" class="form-control edit" ng-model="item[itemCol.dataField]"
                                               yb-number-input decimal-places="3" max="99999" min="1" maxlength="9" disable-decimal="false" decimal-places="3">
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="materialObj.mainMaterialList.length === 0">暂时没有数据</div>
                </div>
            </div>

            <div class="panel-bar clearfix m-t-120">
                <div class="pull-left">
                    <i></i>辅料
                    <span class="m-l-md danger-color">最多只能选择2个辅料</span>
                </div>
            </div>

            <div class="row wrapper-y-xs">
                <div class="col-xs-12 operate-bar font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="selMateriel($event,'showMaterielDismantling')">选择零件</button>
                </div>
            </div>
            <div materiel-selector show-toolbar="toolbarConfig.showMaterielDismantling" ng-if="toolbarConfig.showMaterielDismantling"
                is-purchase="true" dealer-id="orderObj.purchaseOrgId"
                selected-list="materialObj.accessoriesList" replace-or-retrofit-check="true"></div>
            <div class="main-area d-b-60" style="top:265px;height: 400px">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{accessoriesListTbConf.scrollWidth}}">
                            <thead>
                            <tr>
                                <th width="60" class="border-l-none">
                                    操作
                                </th>
                                <th ng-repeat="itemCol in accessoriesListTbConf.tableCol track by $index" width="{{itemCol.width}}">
                                    <div yb-thead-operate ng-model="itemCol" target-width="accessoriesListTbConf.scrollWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="materialObj.accessoriesList.length > 0">
                        <table class="table-fixed border-none" width="{{accessoriesListTbConf.scrollWidth}}">
                            <tbody>
                            <tr ng-repeat="item in materialObj.accessoriesList track by $index">
                                <td width="60" class="font-0">
                                    <button class="btn btn-operate" ng-click="delChoosedMaterial($index)">删除</button>
                                </td>
                                <td ng-repeat="itemCol in accessoriesListTbConf.tableCol track by $index" width="{{itemCol.width}}"
                                    title="{{item[itemCol.dataField]}}">
                                    <div class="spill-dots" ng-if="!itemCol.input">
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)" ng-if="!!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                        <span ng-if="!itemCol.clickFn">
                                        {{item[itemCol.dataField]}}
                                        </span>
                                    </div>

                                    <div ng-if="itemCol.input && itemCol.inputType === 'txt'" class="td-edit pos-r">
                                        <input type="text" class="form-control edit"  ng-model="item[itemCol.dataField]"
                                                yb-number-input decimal-places="3" max="99999" min="1" maxlength="9" disable-decimal="false" decimal-places="3"
                                               ng-class="{'error': !!item.qtyErr}">
                                        <div class="pos-a tool-tips" ng-if="!!item.qtyErr">
                                            <i class="triangle"></i>
                                            <div class="msg">{{item.qtyErrMsg}}</div>
                                        </div>
                                    </div>

                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="materialObj.accessoriesList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center clearfix">
                <button type="button" class="btn btn-primary m-r-sm" ng-click="saveData('edit')">保存</button>
                <button type="button" class="btn btn-default m-r-sm" ng-click="cancel()">取消</button>
            </div>
        </div>
    </div>
</div>